namespace Tekdev.InputValidation
{
    using System;
    using System.Collections;
    using System.Reflection;

    [Serializable]
    internal class QueryStringParamCollection : CollectionBase
    {
		#region Constructor
        internal QueryStringParamCollection()
        {
        }
		#endregion

		#region CollectionBase Methods
        internal int Add(QueryStringParameter parameter)
        {
            return List.Add(parameter);
        }

		internal void Remove(QueryStringParameter parameter)
		{
			List.Remove(parameter);
		}

		internal QueryStringParameter this[int index]
		{
			get { return (QueryStringParameter) base.List[index]; }
			set	{ List[index] = value;	}
		}
		#endregion

		#region Custom Methods
        internal bool Contains(string name)
        {
            for (int i = 0; i < Count; i++)
            {
                QueryStringParameter currentItem = (QueryStringParameter)List[i];
                if (currentItem.CaseSensitive)
                {
                    return string.Equals(currentItem.Name, name);
                }
                if (string.Compare(currentItem.Name, name, true) == 0)
                {
                    return true;
                }
            }
            return false;
        }

        internal QueryStringParameter Find(string name)
        {
            for (int i = 0; i < Count; i++)
            {
                QueryStringParameter currentItem = (QueryStringParameter)List[i];
                if (string.Compare(currentItem.Name, name, true) == 0)
                {
                    return currentItem;
                }
            }
            return null;
        }
		#endregion
    }
}

